﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace ProjectFootball.MVC.Models
{
    public static class LeagueTableItemViewModelExtensions
    {
        public static LeagueTableItemViewModel GetLeagueTableItem(this IEnumerable<LeagueTableItemViewModel> leagueTable, Guid teamGuid)
        {
            var items = from l in leagueTable
                        where l.TeamVersion.TeamGuid == teamGuid
                        select l;

            return items.Count() == 1 ? items.Single() : null;
        }
    }
}